package com.dick.base.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dick.base.model.BusinessBoard;
import com.dick.base.parameter.BoardAddParameter;
import com.dick.base.service.BoardService;
import com.dick.base.util.BaseResult;
import com.dick.base.util.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 库存板接口
 */
@RestController
@RequestMapping("api/boards")
public class BoardApi {

    private static final String TAG = "库存板";

    @Autowired
    private BoardService boardService;

    @ApiOperation(value = "新增", tags = TAG)
    @PostMapping()
    public BaseResult<Void> boardAdd(@RequestBody @Valid BoardAddParameter parameter) {
        boardService.boardAdd(parameter);
        return BaseResult.voidResult();
    }

    @ApiOperation(value = "分页查询", tags = TAG)
    @GetMapping
    public BaseResult<Page<BusinessBoard>> boardPage(BusinessBoard businessBoard, PageInfo pageInfo) {
        return BaseResult.of(boardService.boardPage(businessBoard, pageInfo));
    }
}
